<template>
  <div class="user_box">
    <div class="edit_img" @click="changeShow(true)">
      <NuxtImg src="/images/layout/icon-edit.png" />
    </div>
    <div class="user_avatar">
      <NuxtImg src="/images/user/headsculpture_img_0.png" />
      <div class="userNameBox">
        <div class="userName">{{ user.name }}</div>
        <div>{{ lang.account_signup_time }}：{{ user.signupTime }}</div>
      </div>
    </div>
    <div class="user_info">
      <div class="user_info_box">
        <div class="label">{{ lang.account_user_id }}</div>
        <div class="info">
          <span>{{ user.id }}</span>
        </div>
      </div>
      <div class="user_info_box">
        <div class="label">{{ lang.account_phone }}</div>
        <div class="info">
          <span>{{ user.phone }}</span>
        </div>
      </div>
    </div>
  </div>
  <Edit
    :show="showEdit"
    :user="user"
    @changeShow="changeShow"
    @changeName="changeName"
  />
</template>

<script setup lang="ts">
import Edit from "./Edit.vue";

const lang: any = getCurrentPageLang("setting");
const showEdit = ref(false);

const changeShow = (show: boolean) => {
  showEdit.value = show;
};

// 静态演示数据（后续可用 store/接口替换）
const user = reactive({
  name: "ardzb",
  signupTime: "2025-08-13 03:27:22",
  id: "4031730",
  phone: "+5513999999999",
});
const changeName = (name: string) => {
  user.name = name;
};
</script>

<style scoped lang="scss">
.user_box {
  width: 100%;
  font-size: 0.32rem;
  box-sizing: border-box;
  margin-top: 0.2rem;
  background: #3f2e4b;
  border-radius: 0.44rem;
  color: var(--theme-neutral1);
  position: relative;
  padding: 0.4rem 0.26rem 0.25rem;
}
.edit_img {
  position: absolute;
  width: 0.34rem;
  height: 0.34rem;
  top: 0.7rem;
  right: 0.4rem;
}
.edit_img :deep(img) {
  width: 0.5rem;
  height: 0.5rem;
}
.user_avatar {
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  color: var(--theme-neutral1);
  gap: 0.4rem;
}
.user_avatar :deep(img) {
  width: 1.27rem;
}
.userNameBox {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.userName {
  font-size: var(--font-title2);
  font-weight: 700;
}
.user_info_box {
  display: flex;
  align-items: center;
  margin-bottom: 0.2rem;
}
.label {
  margin-right: 0.45rem;
  width: 2.15rem;
  flex-shrink: 0;
  white-space: nowrap;
  text-align: right;
  font-size: 0.34rem;
  font-weight: 100;
}
.info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 0.9rem;
  background: #2c1d31;
  border: 0.03rem solid var(--border-color);
  padding: 0.35rem 0.26rem;
  width: 100%;
  border-radius: 0.15rem;
  color: #ffd700;
}
</style>
